import http from "@/http/index.ts"
import {IncreaseMachinePricing, IncreaseMachinePricingQueryDto} from './type.ts'

// 新增提升机核价
export const addApi = (data: IncreaseMachinePricing) => {
    return http.post("/increaseMachinePricing/createIncreaseMachinePricing", data)
}

// 获取价格
export const getPriceApi = (data: IncreaseMachinePricing) => {
    return http.post("/increaseMachinePricing/getPrice", data)
}

// 分页条件查询列表
export const getListApi = (data: IncreaseMachinePricingQueryDto) => {
    return http.get("/increaseMachinePricing/getIncreaseMachinePricingList", data)
}

// 编辑提升机核价
export const editApi = (data: IncreaseMachinePricing) => {
    return http.put("/increaseMachinePricing/updateIncreaseMachinePricing", data)
}

// 删除提升机核价
export const deleteApi = (id: number) => {
    return http.delete(`/increaseMachinePricing/deleteIncreaseMachinePricing/${id}`)
}

// 导入提升机核价
export const importIncreaseMachinePricing = (file: File) => {
    const formData = new FormData()
    formData.append('file', file)
    return http.upload("/increaseMachinePricing/import", formData)
}

// 导出提升机核价（返回blob）
export const exportIncreaseMachinePricing = () => {
    const url = `${http['instance'].defaults.baseURL}/increaseMachinePricing/export`
    window.location.href = url
    return Promise.resolve()
}

// 下载导入模板（返回blob）
export const downloadTemplate = () => {
    const url = `${http['instance'].defaults.baseURL}/increaseMachinePricing/downloadTemplate`
    window.location.href = url
    return Promise.resolve()
}

// 更新提升机核价状态
export const updateStatusApi = (params: { id: number; activate: number }) => {
    return http.put('/increaseMachinePricing/updateStatus', params)
} 